<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"          
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <h:body>
        <ui:composition template="templateGeneral.xhtml">
            <ui:define name="title">Spiskovi</ui:define>
            <ui:define name="center">

                

                    <p:growl id="infoMessage" sticky="false"/>

                    <p:tabView id="spiskovi" dynamic="false" orientation="left" effect="fold">
                        <p:tab title="Otvori spisak">
                            <h:form id="otvoriForm">
                            <p:selectOneMenu value="#{spsCtrl.selectedPredmet}">  
                                <p:ajax event="change" listener="#{spsCtrl.onChangePredmet}" />
                                <f:selectItem itemLabel="Odaberi" itemValue="" />  
                                <f:selectItems value="#{spsCtrl.predmetiList}" />  
                            </p:selectOneMenu>
                            <h:panelGrid id="dodaj" columns="2" cellspacing="10">				
                                <h:outputText value="Naziv" style="font-weight: bold"/>
                                <p:inputText value="#{spsCtrl.noviSpisak.naziv}" required="true" requiredMessage="Morate uneti naziv"/>
                                <h:outputText value="Termin" style="font-weight: bold" />
                                <p:calendar value="#{spsCtrl.datum}" pattern="MM/dd/yyyy HH:mm" required="true" requiredMessage="Morate uneti termin"/>
                                <h:outputText value="Mesto" style="font-weight: bold" />
                                <p:inputText value="#{spsCtrl.noviSpisak.mesto}" required="true" requiredMessage="Morate uneti mesto"/>
                                <h:outputText value="Limit" style="font-weight: bold" />
                                <p:inputText value="#{spsCtrl.noviSpisak.ogranicenje}" required="true" requiredMessage="Morate uneti limit"/>					
                                <p:commandButton value="Snimi" actionListener="#{spsCtrl.snimiSpisak}"/>
                            </h:panelGrid> 
                            </h:form>
                        </p:tab>

                        <p:tab title="Zatvori spisak">
                            <h:form id="zatvoriForm">
                            <h:panelGrid columns="1" style="margin-bottom:10px" cellpadding="10">  
                                 <p:selectOneMenu value="#{spsCtrl.selectedPredmet}">  
                                     <p:ajax event="change" listener="#{spsCtrl.onChangePredmet}" update=":spiskovi:zatvoriForm:basic"/>
                                    <f:selectItem itemLabel="Odaberi" itemValue="" />  
                                     <f:selectItems value="#{spsCtrl.predmetiList}" />  
                                </p:selectOneMenu>
                                <p:selectManyMenu id="basic" value="#{spsCtrl.spiskoviSelected}" style="min-height: 40px; min-width: 600px">  
                                    <f:selectItem itemLabel="" itemValue=""/>
                                    <f:selectItems value="#{spsCtrl.spiskoviList}"/>						 
                                </p:selectManyMenu>  
                                
                                <p:commandButton value="Zatvori" ajax="false" actionListener="#{spsCtrl.zakljuciSpisak}"/>
                            </h:panelGrid>
                                </h:form>
                        </p:tab>
                    </p:tabView>

            </ui:define>
        </ui:composition>
    </h:body>
</html>